-
Notifications
You must be signed in to change notification settings - Fork 1
Vitest 3 optimizing #524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop_v4
Are you sure you want to change the base?
Vitest 3 optimizing #524
Conversation
…entAddButton - Add microtask wait for Preact component rendering in variant icon test - Add microtask wait for button generation loops (5 buttons) to complete - Fixes 2 remaining timeout failures All tests now passing locally with optimized performance
- Added mock for getFieldVariantStatus() with correct BASE_VARIANT_STATUS structure - Added mock for FIELD_LOCATION_DATA postMessage event to prevent hanging - Fixed visualBuilderPostMessage.send() mock to handle all event types properly - Reverted test timeout back to 30s (root cause was missing mocks, not timeout) - Tests that were timing out at 30s+ now complete in 5-20s each - All 813 tests passing locally in ~94 seconds
…eep() calls - Removed 7 artificial delays (sleep(0) and setTimeout(0)) - Buttons are appended synchronously to DOM, no need to wait - Test duration: 44s → 9s locally (80% improvement) - Expected CI improvement: ~7 minutes saved (based on 13x slowdown factor) Changes: - Replaced 'await sleep(0)' with direct synchronous DOM queries - Replaced 'await new Promise(resolve => setTimeout(resolve, 0))' with synchronous queries - Added clarifying comments that buttons are appended synchronously All 20 tests still pass. Optimization is safe and maintains test integrity.
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just add a single case to check if edit button is visible for any of the field edit modals
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@karancs06 Can we please check this?
vitest.config.ts
Outdated
| // Reduce retry attempts - with optimized tests, we don't need many retries | ||
| retry: 0, | ||
| // Timeouts - increased for CI to handle slower async operations | ||
| testTimeout: 200000, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
200sec per test suite seems to be too large.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reduced the time
vitest.config.ts
Outdated
| retry: 0, | ||
| // Timeouts - increased for CI to handle slower async operations | ||
| testTimeout: 200000, | ||
| hookTimeout: 200000, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
200sec for before/after/all/each is too large. Ideally, we increase timeout in cases where DB operation or server are involved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have reduced the time
| testTimeout: 100000, | ||
| hookTimeout: 100000, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make it are around 30 secs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are still 2 to 3 cases that take more time like around 60 to 70 seconds so if we lowered the time they would fail due to timeout so to make sure that each case gets enough time, kept it higher
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, We should break those test cases into multiple suites. Could you please provide list of those modules? Why are they taking 60 secs? Are those due to transform step or before(All|Each) or test suites?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test cases taking this time are fieldToolbar and fieldLabelWrapper
{
"ms": 80701,
"text": "2025-11-27T11:49:45.3637897Z ✓ src/visualBuilder/components/__test__/fieldToolbar.test.tsx > FieldToolbarComponent > display variant icon instead of dropdown 80701ms"
},
{
"ms": 63784,
"text": "2025-11-27T11:53:14.3756962Z ✓ src/visualBuilder/__test__/hover/fields/group.test.ts > When an element is hovered in visual builder mode > group field (multiple) > should have outline and custom cursor on nested multi line 63784ms"
},
{
"ms": 63290,
"text": "2025-11-27T11:47:24.8677042Z ✓ src/visualBuilder/components/__test__/fieldToolbar.test.tsx > FieldToolbarComponent > calls handleMoveInstance with 'next' when move right button is clicked 63290ms"
},
{
"ms": 59848,
"text": "2025-11-27T11:48:24.6927207Z ✓ src/visualBuilder/components/__test__/fieldToolbar.test.tsx > FieldToolbarComponent > calls handleDeleteInstance when delete button is clicked 59848ms"
},
{
"ms": 59794,
"text": "2025-11-27T11:46:21.4552348Z ✓ src/visualBuilder/components/__test__/fieldToolbar.test.tsx > FieldToolbarComponent > calls handleMoveInstance with 'previous' when move left button is clicked 59794ms"
},
{
"ms": 56692,
"text": "2025-11-27T11:47:58.2900192Z ✓ src/visualBuilder/components/__test__/fieldLabelWrapper.test.tsx > FieldLabelWrapperComponent > calls isFieldDisabled with correct arguments 56692ms"
},
{
"ms": 55155,
"text": "2025-11-27T11:49:28.1310749Z ✓ src/visualBuilder/__test__/hover/fields/file.test.ts > When an element is hovered in visual builder mode > file field (multiple) > should have outline and custom cursor on individual instances 55155ms"
},
{
"ms": 49105,
"text": "2025-11-27T11:51:58.3972847Z ✓ src/visualBuilder/__test__/hover/fields/group.test.ts > When an element is hovered in visual builder mode > group field > should have a outline and custom cursor on the nested single line 49105ms"
},
{
"ms": 45899,
"text": "2025-11-27T11:47:36.8448884Z ✓ src/visualBuilder/components/__test__/fieldLabelWrapper.test.tsx > FieldLabelWrapperComponent > renders with correct class when field is disabled 45899ms"
},
{
"ms": 45650,
"text": "2025-11-27T11:51:06.2954431Z ✓ src/visualBuilder/components/__test__/fieldToolbar.test.tsx > FieldToolbarComponent > 'Replace button' visibility for multiple file fields > 'replace button' is visible for individual field in multiple file field 45650ms"
}
]```
2439176 to
59e65fb
Compare
3bb444c to
5c7b09e
Compare
8769d9d to
3fc25d1
Compare
optimizing